<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
        $(function () {
            $("#validForm").validate({
                submitHandler: function (form) {
                    $("#validForm input[name|='dy']").each(function () {
                        var name = $(this).attr("name");
                        $(this).attr("name", name.substring(3, name.lastIndexOf("-")));
                    });
                    form.submit();
                }
            });

          $("input[name='name']").focus();

        });

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optMulti(form, action, msg) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }

        function liveSave(form, action, msg) {
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>版本更新信息 - <s:message code="${oprt=='edit' ? 'edit' : 'create'}"/></h1>
</div>
<c:set var="numberExist"><s:message code="vote.number.exist"/></c:set>
<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="${oprt=='edit' ? 'update' : 'save'}.do" method="post">
            <tags:search_params/>
            <f:hidden name="id" value="${bean.id}"/>
            <f:hidden name="position" value="${position}"/>
            <input type="hidden" id="redirectLive" name="redirect" value="edit"/>
            <div class="box-header with-border">
                <div class="btn-toolbar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:appversion:create">
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='create.do?stat=${stat}';"<c:if
                                    test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message
                                    code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:appversion:delete">
                            <button class="btn btn-default" type="button"
                                    onclick="if(confirmDelete()){location.href='delete.do?ids=${bean.id}';}"
                                    <c:if test="${oprt=='create'}"> disabled="disabled"</c:if>><s:message
                                    code="delete"/></button>
                        </shiro:hasPermission>
                    </div>

                    <div class="btn-group">
                        <button class="btn btn-default" type="button"
                                onclick="location.href='list.do';"><s:message
                                code="return"/></button>
                    </div>
                </div>
            </div>
            <div class="box-body">

                <div class="row">
                    <div class="col-sm-8">
                        <label class="col-sm-2 control-label"><em class="required">*</em>上传apk包:</label>
                        <div class="input-group">
                            <span class="input-group-addon"><s:message code="fileUrl"/></span>
                            <f:text class="form-control" id="file" name="address" value="${bean.address}" maxlength="500"/>
                            <span class="input-group-btn">
						      	<button class="btn btn-default" id="fileButton" type="button"><s:message code='choose'/></button>
						      	<span id="fileSwfButton"></span>
						      	<button class="btn btn-default" type="button" class="swfbutton"><s:message code="upload"/></button>
					      		<button class="btn btn-default" type="button" id="fileSwfCancel" onclick="fileSwfUpload.cancelQueue();" disabled><s:message code="cancel"/></button>
                            </span>
                        </div>
                        <%--<div class="input-group">--%>
                        <%--<span class="input-group-addon"><s:message code="fileLength"/></span>--%>
                        <%--<span class="input-group-btn">--%>
                        <%--<button class="btn btn-default" id="fileButton" type="button"><s:message code='choose'/></button>--%>
                        <%--<span id="fileSwfButton"></span>--%>
                        <%--<button class="btn btn-default" type="button" class="swfbutton"><s:message code="upload"/></button>--%>
                        <%--<button class="btn btn-default" type="button" id="fileSwfCancel" onclick="fileSwfUpload.cancelQueue();" disabled><s:message code="cancel"/></button>--%>
                        <%--</span>--%>
                        <%--</div>--%>
                        <div id="fileSwfProgress"></div>
                        <script type="text/javascript">
                          $(function() {
                            Cms.f7.uploads("file","fileName",{
                              settings: {"title": "<s:message code="webFile.chooseUploads"/>"}
                            });
                          });
                        </script>
                        <script type="text/javascript">
                          var fileSwfUpload = Cms.swfUploadFile("file",{
                            jsessionid: "<%=request.getSession().getId()%>",
                            file_size_limit: "${GLOBAL.upload.fileLimit}",
                            file_types: "${GLOBAL.upload.fileTypes}"
                          });
                        </script>
                    </div>
                </div>
                <div class="row" style="margin-top: 10px;">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em>更新描述:</label>
                            <div class="col-sm-10">
                                <f:textarea class="form-control required" name="description" value="${bean.description}" maxlength="500" rows="10"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em>是否强制更新: </label>
                            <div class="col-sm-10">
                                <select class="form-control required" name="force">
                                    <c:if test="${bean.force}">
                                        <f:option value="1" selected="1" >是</f:option>
                                        <f:option value="0" selected="1" >否</f:option>
                                    </c:if>
                                    <c:if test="${!bean.force}">
                                        <f:option value="1" selected="0" >是</f:option>
                                        <f:option value="0" selected="0" >否</f:option>
                                    </c:if>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>




            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>版本序号:</label>
                        <div class="col-sm-10">
                            <f:text name="versionCode" value="${bean.versionCode}"
                                    class="form-control required" maxlength="50"/>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>版本号:</label>
                        <div class="col-sm-10">
                            <f:text name="versionName" value="${bean.versionName}"
                                    class="form-control required" maxlength="50"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-8">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><em class="required">*</em>是否发布: </label>
                        <div class="col-sm-10">
                            <select class="form-control required" name="publish">
                                <f:option value="2" selected="${bean.publish}" >否</f:option>
                                <f:option value="1" selected="${bean.publish}" >是</f:option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>

            </div>

            <%-----------------------------------------------------------[  按钮 保存 如下:  ]----------------------------------------------------------------------------------%>
            <div class="box-footer">
                <shiro:hasPermission name="ext:appversion:save">
                <button class="btn btn-primary" type="submit" onclick="$('#redirectLive').val('edit');"><s:message
                        code="save"/></button>
                <button class="btn btn-default" type="submit" onclick="$('#redirectLive').val('list');"><s:message
                        code="saveAndReturn"/></button>
                <c:if test="${oprt=='create'}">
                    <button class="btn btn-default" type="submit" onclick="$('#redirectLive').val('create');"><s:message
                            code="saveAndCreate"/></button>
                </c:if>
                </shiro:hasPermission>

            </div>
        </form>
    </div>
</div>
</div>
</body>
</html>